package cn.wolfcode.crm.util;

import cn.wolfcode.crm.domain.Employee;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

public class UserContext {
    private UserContext() {
    }
    public static HttpServletRequest getRequest() {
        return ((ServletRequestAttributes) (RequestContextHolder.getRequestAttributes())).
                getRequest();
    }


    public static Employee getCurrentUser() {
        return (Employee) SecurityUtils.getSubject().getPrincipal();
//        return (Employee) getSession().getAttribute(USER_IN_SESSION);
    }
    public static Session getSession() {
        return SecurityUtils.getSubject().getSession();
    }
}
